using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAttackState : PlayerState
{
    private bool isAttackDone;
    private Weapon weapon;

    public PlayerAttackState(Player player, PlayerStateMachine stateMachine, string animBoolName,Weapon weapon) : base(player, stateMachine, animBoolName)
    {
        this.weapon = weapon;
        weapon.OnExit += ExitHandler;
    }

    public override void Enter()
    {
        base.Enter();
        isAttackDone = false;
        weapon.Enter();
    }

    public override void LogicUpdate()
    {
        base.LogicUpdate();
        if (isAttackDone)
        {
            stateMachine.ChangeState(player.IdleState);
        }
    }

    public override void PhysicsUpdate()
    {
        base.PhysicsUpdate();
    }

    private void ExitHandler()
    {
        isAttackDone = true;
    }
}
